<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>厂商详情</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="Wrapper">
	<div id="pageInTab" class="pageInTab">
		<div tabid="tabA" title="基本信息" lselected="true">
            <form id="formSet1">
            	<div class="fieldset1 tabel_col clearFix">
            		<div class="caption">
                        <span class="title">厂商信息</span>
                    </div>
                    <div class="fieldBox col_33">
	                    <div class="label">厂商名称</div>
	                    <div class="field">
	                    	<span name="mfrName" id="mfrName">&nbsp;</span>
	                    	<input name="mId" id="mId" type="hidden" value="${id }">
	                    </div>
	                </div>
					<div class="fieldBox col_50">
						<div class="label">社会统一信用代码</div>
						<div class="field">
							<span name="succ" id="succ"></span>
						</div>
					</div>
                    <div class="fieldBox col_66">
	                    <div class="label">厂商地址</div>
	                    <div class="field">
	                    	<span name="mfrAddr" id="mfrAddr">&nbsp;</span>
	                    </div>
	                </div>
                    <div class="fieldBox col_33">
	                    <div class="label">办公电话</div>
	                    <div class="field">
	                    	<span name="mfrTel" id="mfrTel">&nbsp;</span>
	                    </div>
	                </div>
					<div class="fieldBox col_100">
						<div class="label">放款方式</div>
						<div class="field">
							<span name="payTypCdNm" id="payTypCdNm">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_66_auto">
						<div class="label">区域</div>
						<div class="field">
							<!-- <input name="rgnPrCd" id="rgnPrCd" type="text" class="ui-textbox" value=""> -->
							<jsp:include page="../../system/sysRegion/region.jsp"
										 flush="true">
								<jsp:param name="regionShowLvl" value="2" />
							</jsp:include>
							<span class="requiredSymbol">*</span>
						</div>
					</div>

					<div class="fieldBox col_33">
						<div class="label">经销品牌(卡车类)</div>
						<div class="field">
							<span name="tkBrCdNms" id="tkBrCdNms">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">经销品牌(乘用车类)</div>
						<div class="field">
							<span name="carBrCdNms" id="carBrCdNms">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">经销品牌(客车类)</div>
						<div class="field">
							<span name="busBrCdNms" id="busBrCdNms">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_100">
						<div class="label">其他信息</div>
						<div class="field">
							<span name="otherInfo" id="otherInfo">&nbsp;</span>
						</div>
					</div>
            	</div>
            	<div class="sqPanel">
	                <div class="sqPanel_head inL">
	                    <span>社会关系/家庭成员</span>
	                </div>
	                <div class="sqPanel_body">
	                    <div id="ligergrid_A1" class="sq-grid"></div>
	                </div>
	            </div>
                
            </form>
        </div>
		<div tabid="tabB" title="资料信息">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
		<div tabid="tabC" title="授信备案">
	        <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
	    </div>
	</div>
</div>
</div>


<script type="text/javascript">

var loadedTabs=[];
var mfrId = '${id}';
var isCheckVerify = '${isCheckVerify}';
var isDetail = '${isDetail}';
var isFlow = '${isFlow}';
var isMdfPayTyp = '${isMdfPayTyp}';
var isModify = '${isModify}';
var mfrsocialRlGrid ;

$(function () {
    $("#formSet1").ligerForm({
        validate : true
    });

    initTab();
 	 //初始化数据
    initData();
    
});


function initData(){
	var _id = $("#mId").val();
    var currentOrgCd = '${currentOrgCd}';
    var isFlow = '${isFlow}';
	var _url = '<%=path%>/mfr/mfrBscInfo/getById.do';
	$.ajax({
		type: 'get',
		dataType:'json',
        data:{id:_id,currentOrgCd:currentOrgCd,isFlow:isFlow},
		url: _url,
		success:function(msg){
			 if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 $.ligerDialog.warn(msg.info);
			 }
		}
	});

    initMfrRlGrid();
}

//设置页面数据
function setData(data){
	
	var form = new liger.get("formSet1");
	$("#mfrName").html(data.mfrName);
	$("#mfrAddr").html(data.mfrAddr);
	$("#mfrTel").html(data.mfrTel);
	$("#succ").html(data.succ);
    $("#payTypCdNm").html(data.payTypCdNm);

    //区域数据处理
    setRgnProvCdUpdataValue(data.rgnPrCd);
    setRgnCityCdUpdataValue(data.rgnCyCd);
    setRegionSelectDataChange();
    disabledRgnProvCd();
    disabledRgnCityCd();

    $("#tkBrCdNms").html(data.tkBrCdNms);
    $("#carBrCdNms").html(data.carBrCdNms);
    $("#busBrCdNms").html(data.busBrCdNms);
    $("#otherInfo").html(data.otherInfo);

}

//初始化Tab页
function initTab(){
	pageInTab = $("#pageInTab").ligerTab({
        height: 'auto',
        contextmenu: false,
        minIframeHeight: 450,
        onBeforeSelectTabItem: function (tabid) {
        	var _mId = $("#mId").val();
        	if(tabid!="tabA"){
                if(!_mId){
                	top.$.ligerDialog.SQalert({content: "请确认厂商基本信息已存在", SQ_type: "warning"});
                	return false;
                }
        	}
        },
        onAfterSelectTabItem: function(tabid) {
            if (loadedTabs.indexOf(tabid)<0) {
            	var _mId = $("#mId").val();
            	if(tabid!="tabA"){
                	if(!_mId){
                		 top.$.ligerDialog.SQalert({content: "请确认厂商基本信息已存在", SQ_type: "warning"});
                         return false; 
                	}
            	}
                loadedTabs.push(tabid);
                switch (tabid){
                    case "tabB": //厂商资料
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/mfr/mfrBscInfo/toMfrFileAddPage.do?mfrId="+mfrId+"&isDetail="+isDetail+"&isModify="+isModify+"&isCheckVerify="+isCheckVerify+"&isFlow="+isFlow+"&isMdfPayTyp="+isMdfPayTyp);
                        break;
                    case "tabC"://备案账号
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/mfr/mfrbankacc/toListPage.do?mfrId="+mfrId+"&isDetail="+isDetail+"&isModify="+isModify+"&isCheckVerify="+isCheckVerify+"&isFlow="+isFlow+"&isMdfPayTyp="+isMdfPayTyp);
                        break;
                    case "tabE"://相关项目
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/product/mfrInfo/toMfrPrjBscInfoDetailList.do?mfrId="+mfrId);
                        break;
                }
            };
            SetIframe_height();
        }
    });
};

//初始化主要人员信息
function initMfrRlGrid() {
    var _mId = $("#mId").val();
    if(!_mId){
        return; //验证不通过，不执行以下代码
    }
    mfrsocialRlGrid = $("#ligergrid_A1").ligerGrid({
        usePager: false,
        url: '<%=path%>/mfr/mfrrlpsn/initList.do?mfrId=' +_mId,
        method : 'get',
        columns: [
            { display: '联系人姓名', name: 'rlNm', minWidth: 100},
            { display: '联系人类型', name: 'rlTypCdNm', minWidth: 140},
            { display: '证件类型', name: 'certTypCdNm', minWidth: 140},
            { display: '证件号', name: 'certNo', minWidth: 200, render: function(rowdata, rowindex, value){
                if (value != null && value != '') {
                    return '<a href="javascript:toCertNoCheckPage(\''+value+'\');" class="sq-button-hasicon link">'
                        + '<i class="sqBtnIco_1"></i></a>'
                        + value;
                }
            }},
            { display: '联系电话', name: 'tel', minWidth: 150},
            { display: '备注', name: 'rlRem', minWidth: 150},
            { display: '工商信息校验', name: 'checkVerify', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    var h = "";
                    if(isCheckVerify && isCheckVerify == 1){
                        if(!rowdata.busInfoVerify || rowdata.busInfoVerify == 2){
                            h+= '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(1,\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\',\''+rowdata.rlTypCd+'\');">验证</a>'
                        }else{
                            h +='<div class="sq-button sq-button-round disabled">已校验</div>'
                        }
                    }
                    return h;
                }
            },
            { display: '工商信息校验结果', name: 'busInfoVerify', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    if(rowdata.busInfoVerify == 1){
                        return "一致" ;
                    }else if(rowdata.busInfoVerify == -1){
                        return "不一致";
                    }else if(rowdata.busInfoVerify == 0){
                        return "未查得";
                    }else{
                        return "";
                    }
                }
            },
            { display: '三要素校验（机构1）', name: 'PYCheck', minWidth: 150,
                render: function(rowdata, rowindex, value){

                    var h = "";
                    if(isCheckVerify && isCheckVerify == 1){
                        if(!rowdata.pyPerVerify || rowdata.pyPerVerify == 2){
                            h+= '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(2,\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\',\''+rowdata.rlTypCd+'\');">验证</a>'
                        }else{
                            h+='<div class="sq-button sq-button-round disabled">已校验</div>'
                        }
                    }
                    return h;
                }
            },
            { display: '三要素校验结果1', name: 'pyPerVerify', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    if(rowdata.pyPerVerify == 1){
                        return "一致" ;
                    }else if(rowdata.pyPerVerify == -1){
                        return "不一致";
                    }else if(rowdata.pyPerVerify == 0){
                        return "未查得";
                    }else{
                        return "";
                    }
                }
            },
            { display: '三要素校验（机构2）', name: 'TDCheck', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    var h = "";
                    if(isCheckVerify && isCheckVerify == 1){
                        if(!rowdata.tdPerVerify || rowdata.tdPerVerify == 2){
                            h+= '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(3,\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\',\''+rowdata.rlTypCd+'\');">验证</a>'
                        }else{
                            h +='<div class="sq-button sq-button-round disabled">已校验</div>'
                        }
                    }
                    return h;
                }
            },
            { display: '三要素校验结果2', name: 'tdPerVerify', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    if(rowdata.tdPerVerify == 1){
                        return "一致" ;
                    }else if(rowdata.tdPerVerify == -1){
                        return "不一致";
                    }else if(rowdata.tdPerVerify == 0){
                        return "未查得";
                    }else{
                        return "";
                    }
                }
            },
            { display: '三要素校验（机构3）', name: 'BRCheck', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    var h = "";
                    if(isCheckVerify && isCheckVerify == 1){
                        if(!rowdata.brPerVerify  || rowdata.brPerVerify == 2){
                            h+= '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(4,\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\',\''+rowdata.rlTypCd+'\');">验证</a>'
                        }else{
                            h +='<input class="sq-button sq-button-round disabled" type="button" value="已校验" disabled>'
                        }
                    }
                    return h;
                }
            },
            { display: '三要素校验结果3', name: 'brPerVerify', minWidth: 150,
                render: function(rowdata, rowindex, value){
                    if(rowdata.brPerVerify == 1){
                        return "一致" ;
                    }else if(rowdata.brPerVerify == -1){
                        return "不一致";
                    }else if(rowdata.brPerVerify == 0){
                        return "未查得";
                    }else{
                        return "";
                    }
                }
            },

        ],
        pageSize:10,
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        isScroll: false,
        //checkbox:true,
        rownumbers:true,
        onAfterShowData: function() {
            SetIframe_height ();
        }
    });
};

/**
 * 三要素校验
 * @param type
 * @param dataId
 * @param rlNm
 * @param certNo
 * @param tel
 * @param rlTypCd
 */
function checkRlPsn(type,dataId,rlNm,certNo,tel,rlTypCd){
    var _type ;
    if(type == 1){
        _type = 'verify' ;
    }
    if(type == 2){
        _type = 'PY' ;
    }
    if(type == 3){
        _type = 'TD' ;
    }
    if(type == 4){
        _type = 'BR' ;
    }
    var _url = '<%=path%>/mfr/mfrBscInfo/checkRlPsn.do';
    $.ajax({
        type: 'post',
        dataType : 'json',
        data:{
            type:_type,
            rlPsnId:dataId,
            rlNm:rlNm,
            certNo:certNo,
            tel:tel,
            mfrId:mfrId,
            rlTypCd:rlTypCd,
            applyPsnId:null //如果变更流程，需要加上
        },
        url:_url,
        success:function(msg){
            if(msg.success == 1){
                initMfrRlGrid();
            }else{
                initMfrRlGrid()
            }
        }
    });
}



</script>



</body>
</html>
